package com.angel.components.validators{
	import mx.validators.ValidationResult;
	import mx.validators.Validator;

	public class BaseValidator extends Validator {
		
		// Define Array for the return value of doValidation().
        protected var results:Array;

		[Inspectable(category="General", enumeration="edit,submit,all", defaultValue="all")]      
        public var modeValidate:String;
		
		
		protected function addErrorValidationResult(errorCode:String, errorMessage:String):void{
			results.push(new ValidationResult(true, null, errorCode, errorMessage));
		}
		
		 // Define the doValidation() method.
        override protected function doValidation(value:Object):Array {

            // Clear results Array.
            results = [];
			if(modeValidate == "all" || modeValidate == "submit"){
				// Call base class doValidation().
				results = super.doValidation(value);      
	            // Return if there are errors.
	            if (results.length > 0){
	                return results;
	            }
			}
 
            return results;
        }
			
		
	}
}